
import { ApiRes, BannerItem, BrandItem, HotItem, NewItem, ProductItem, SpecialItem } from '@/types/data'
import  request  from '@/utils/request'
import {defineStore} from 'pinia'

export default defineStore('home',{
  state() {
      return {
          bannerList : [] as BannerItem[],
          newList : [] as NewItem[],
          hotList : [] as HotItem[],
          brandList : [] as BrandItem[],
          productList : [] as ProductItem[],
          specialList : [] as SpecialItem[]
      }
  },
  actions:{
   async getBannalList (){
      const res = await request.get<ApiRes<BannerItem[]>>('/home/banner')
     this.bannerList = res.data.result
   },
   async getNewlList (){
    const res = await request.get<ApiRes<NewItem[]>>('/home/new')
   this.newList = res.data.result
 },
  async getHotlList (){
    const res = await request.get<ApiRes<HotItem[]>>('/home/goods')
    this.hotList = res.data.result
 
},
async getbrandlList (){
  const res = await request.get<ApiRes<BrandItem[]>>('/home/brand')
  this.brandList = [...res.data.result,...res.data.result]

},
async getproductList (){
  const res = await request.get<ApiRes<ProductItem[]>>('/home/goods')
  this.productList =res.data.result

},
async getspecialList (){
  const res = await request.get<ApiRes<SpecialItem[]>>('/home/special')
  
  this.specialList =res.data.result

},
   
  }
})